package jangdolbaeng2.seller.dao;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import jangdolbaeng2.db.MybatisConfig;
import jangdolbaeng2.vo.Shop_qaVO;
import jangdolbaeng2.vo.spamVO;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

public class spamDAO {
	SqlSessionFactory factory = MybatisConfig.getSqlSessionFactory();
	
	public List<spamVO> spamlist(spamVO vo){		
		SqlSession ss = factory.openSession();
		List<spamVO> spamlist = null;
		try{
			spamlist = ss.selectList("spam.spamlist", vo);
			ss.commit();
		}catch(Exception e) {
			e.printStackTrace();
		}
		finally {
			if (ss != null) ss.close();
		}
		System.out.println("spamList 가져온 값 : "+spamlist);
		return spamlist;
	}
	
	public void inputspam(spamVO vo){
		SqlSession ss = factory.openSession();
		try {
			System.out.println("디비 넣기 전 vo :"+vo);
			ss.insert("spam.inputspam", vo);
			ss.commit();
		} catch (Exception e) {
			e.printStackTrace();
		}
		finally {
			if (ss != null) ss.close();
		}
		return;
	}
	
	public void del_spamlist(spamVO vo){
		SqlSession ss = factory.openSession();
		try {
			System.out.println("디비 넣기 전 vo :"+vo);
			ss.delete("spam.del_spamlist", vo);
			ss.commit();
		} catch (Exception e) {
			e.printStackTrace();
		}
		finally {
			if (ss != null) ss.close();
		}
		return;
	}
	
	public List<Shop_qaVO> check_spam(){
		SqlSession ss = factory.openSession();
		List<Shop_qaVO> vo = null;
		try {
			Map<String, Object> map = new HashMap<String, Object>();
			List<String> list = new ArrayList<String>();
			list.add("야옹");
			list.add("체크");
			map.put("list", list);
			vo = ss.selectList("spam.check_spam",map);
			System.out.println("test: "+vo);
			ss.commit();
		} catch (Exception e) {
			e.printStackTrace();
		}
		finally {
			if (ss != null) ss.close();
		}
		 return vo;		
	}
}
